package com.czkt.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czkt.entity.vo.BasDictAndCstCustomer;
import com.czkt.entity.vo.BasDictAndService;
import com.czkt.service.SvrRptService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class SvrRptController {

    @Resource
    SvrRptService svrRptService;

    @RequestMapping("/svrRpt/list")
    public String svrRptList(@RequestParam(defaultValue = "1") Integer pageIndex,
                             @RequestParam(defaultValue = "2") Integer pageSize,
                             Model model){
        IPage<BasDictAndService> page = svrRptService.selectBasDictByService(pageIndex,pageSize);
        model.addAttribute("page",page);
        String[] svrRptName = svrRptService.selectBasDictBySvr().stream()
                .map(BasDictAndService::getDictItem)
                .toArray(String[]::new);
        String[] svrRptNumber = svrRptService.selectBasDictBySvr().stream()
                .map(BasDictAndService::getSvrType)
                .toArray(String[]::new);
        model.addAttribute("svrRptName",svrRptName);
        model.addAttribute("svrRptNumber",svrRptNumber);
        return "/svrRpt/list";
    }
}
